public class ModifyString {
    public String modifyString(String s) {
        int n = s.length();
        char[] ch = s.toCharArray();
        for(int i = 0; i < n; i++) {
            if(ch[i] == '?') {
                for(char change = 'a'; change <= 'c'; change++) {
                    if((i > 0 && change == ch[i - 1]) || (i < n -1 && change == ch[i + 1])) {
                        continue;
                    }
                    ch[i] = change;
                    break;
                }
            }
        }
        return new String(ch);
    }
}
